home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: id.dtu.dk!news!jl
- From: jl@id.dth.dk (J°rn Lind-Nielsen)
- Subject: Output to file vs. cout
- Message-ID: <JL.96Mar7165152@thyme.id.dth.dk>
- Sender: news@id.dtu.dk (NetNews)
- Organization: Department of Computer Science, The Technical University of
- Denmark
- Distribution: comp
- Date: Thu, 7 Mar 1996 21:51:52 GMT
-
-
- Here's another of the probs that comes from porting C to C++:
-
- - I want to be able to redirect program output to either a file or cout.
- Typically this would be selected by a commandline option ("-o outfile").
-
- - In C I would do something like this:
-
-
- main()
- {
- FILE *outputfile;
-
- if (commandline == do_output_to_file)
- outputfile = stdout;
- else
- outputfile = fopen(passed_filename, "w");
-
- fprintf(outfile, "Hello world\n");
-
- fclose(outfile); /* Maybe - not allways necassary */
- }
-
-
-
- - The question is: How is this done in C++ ?
-
-
- ------------------------------------------------------------------------
- From: Jorn Bo Lind-Nielsen /"""\ Bergsoe Kollegiet 2104
- E-mail: jl@it.dtu.dk |o o| DK - 2850 Naerum
- --------------------------------ooo-U-ooo-------------------------------
- A Norton Commander for Unix ? FTP duroc.ds-data.dk /pub/uc
- ------------------------------------------------------------------------
- --
- ------------------------------------------------------------------------
- From: Jorn Bo Lind-Nielsen /"""\ Bergsoe Kollegiet 2104
- E-mail: jl@it.dtu.dk |o o| DK - 2850 Naerum
- --------------------------------ooo-U-ooo-------------------------------
- A Norton Commander for Unix ? FTP duroc.ds-data.dk /pub/uc
- ------------------------------------------------------------------------
-